﻿<?php
	session_start();
	include "include.php";
	mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die(mysql_error());
	mysql_select_db(DB_NAME);
?>
<html>
<head>
<title><?php echo $SITE_TITLE ?> - Edit Loot</title>
<link rel="stylesheet" type="text/css" href="main.css" /></head>
<link rel="stylesheet" type="text/css" href="ui.datepicker.css" />
<style type="text/css">.embed + img { position: relative; left: -21px; top: -1px; }</style>
<script type="text/javascript" src="jquery-1.2.6.js"></script>
<script type="text/javascript" src="ui.datepicker.js"></script>

<script type="text/javascript">
$(function(){ $("#loot_date").datepicker({ 
    showOn: "both"
}).addClass("embed"); }); 
	
	function item_lookup(items_name) {
		if(items_name.length == 0) {
			// Hide the suggestion box.
			$('#item_suggestions').hide();
		} else {
			$.post("rpc_item.php", {queryString: ""+items_name+""}, function(data){
				if(data.length >0) {
					$('#item_suggestions').show();
					$('#item_autoSuggestionsList').html(data);
				}
			});
		}
	} // lookup
	
	function item_fill(thisValue) {
		$('#items_name').val(thisValue);
		setTimeout("$('#item_suggestions').hide();", 200);
	}
	function player_lookup(players_name) {
		if(players_name.length == 0) {
			// Hide the suggestion box.
			$('#player_suggestions').hide();
		} else {
			$.post("rpc_player.php", {queryString: ""+players_name+""}, function(data){
				if(data.length >0) {
					$('#player_suggestions').show();
					$('#player_autoSuggestionsList').html(data);
				}
			});
		}
	} // lookup
	
	function player_fill(thisValue) {
		$('#players_name').val(thisValue);
		setTimeout("$('#player_suggestions').hide();", 200);
	}
	
</script>
</head>
<body>
<div id="container">
<div id="top">
<h1><?php echo $SITE_TITLE ?></h1>
</div>
<div id="leftnav">
<?php include "leftnav.php" ?>
</div>
<div id="content">
<?php
	$sql = "SELECT * from loots WHERE loots_id=" . $_GET["loots_id"] . ";";
	$result = mysql_query($sql);
	$myrow = mysql_fetch_row($result);
?>
	<div>
		<form action="edit_loot_process.php" method="post">
			<div>
				Item looted:
				<input type="text" size="30" name="items_name" value="<?php echo get_item_name($myrow[3]) ?>" id="items_name" onkeyup="item_lookup(this.value);" onblur="item_fill();" />
				Player: 
				<input type="text" size="30" name="players_name" value="<?php echo ucwords(get_player_name($myrow[1])) ?>" id="players_name" onkeyup="player_lookup(this.value);" onblur="item_fill();" />
				<input type="text" size="10" name="loot_date" value="<?php echo date("m/d/Y", $myrow[2]) ?>" id="loot_date"/> 
				<?php
					if($myrow[4] == 0) {
				?>
						<input type="checkbox" name="loots_type" id="loots_type"> Rot
				<?php
					}
					else {
				?>
						<input type="checkbox" name="loots_type" id="loots_type" checked="checked"> Rot
				<?php
					}
				?>
				<input type="hidden" name="loots_id" id="loots_id" value="<?php echo $_GET["loots_id"] ?>">
				</div>
			
			<div class="suggestionsBoxItem" id="item_suggestions" style="display: none;">
				<div class="suggestionList" id="item_autoSuggestionsList">
					&nbsp;
				</div>
			</div>
			<div class="suggestionsBoxPlayer" id="player_suggestions" style="display: none;">
				<div class="suggestionList" id="player_autoSuggestionsList">
					&nbsp;
				</div>
			</div>
			<INPUT type="submit" value="Send"> <INPUT type="reset">
		</form>
	</div>
	<a href="delete_loot.php?loots_id=<?php echo $_GET["loots_id"] ?>">Delete this loot</a>
</div>
<div id="footer">
<?php include "footer.php" ?>
</div>
</div>
</body>
</html>
